#!/bin/ksh
# @(#)34        1.14  src/sysmgt/dsm/bin/wsm.sh, websm, r51.hsc, hsc_wsm_060304 1/12/04 14:42:43

    USAGE="Usage: wsm \t[-host    <host name of managing machine>] \
\t\t[-fastpath  [?] | [list] | [<plugin>]] \
\t\t[-port    <inetd port>] \
\t\t[-profile <pathname of wconsole.pref file>] \
\t\t[-user    <login name>]"

#==============================================================================
usage()
{
     dspmsg websm.cat 10 "$USAGE"
     echo
     exit 1
}


#==============================================================================
# Main
#==============================================================================

# Get fully qualified hostname

hostname=`hostname`
hostname=`LANG=C host $hostname` | awk '{print $1}'
port=9090
profile=""
user=""
fastpath=""


while [ $# -gt 0 ]
do
   case $1 in
      -fastpath )
           shift 1
           if [ $# -eq 0 ]
           then
              usage $0
           else
              fastpath="-fastpath $1"
           fi
           ;;
      -host )
           shift 1
           if [ $# -eq 0 ]
           then
              usage $0
           else
	      hostname=$1
	      host $1 >/dev/null 2>&1 && LANG=C host $1 | read hostname junk
           fi
           ;;
      -port )
           shift 1
           if [ $# -eq 0 ]
           then
              usage $0
           else
              websmargs="$websmargs -Dport=$1"
           fi
           ;;
      -profile )
           shift 1
           if [ $# -eq 0 ]
           then
              usage $0
           else
              profile="-profile $1"
           fi
           ;;
      -lang )
	    shift 1 
	    if [ $# -eq 0 ]
	    then
		usage $0
	    else
		export LANG="$1"
	    fi
	    ;;
      -user )
           shift 1
           if [ $# -eq 0 ]
           then
              usage $0
           else
              user="-user $1"
           fi
           ;;
      -? )
	   usage $0
	   ;;
      * )
	   javaargs="$javaargs $1"
   esac
   shift 1
done


if [ -f /var/websm/config/user_settings/websm.policy ] ; then
   javaargs="$javaargs  -Djava.security.policy=/var/websm/config/user_settings/websm.policy"
else
   javaargs="$javaargs -Djava.security.policy=/usr/websm/config/factory_defaults/websm.policy"
fi


export W_HEAP_MIN_SIZE=20
export W_HEAP_INC_SIZE=6
export W_BIND_PROC=yes


#echo
#echo /usr/websm/bin/wjava $websmargs $javaargs -Dawt.appletWarning=\"Remote class window\" com.ibm.websm.console.WConsole $hostname $profile $user $fastpath

/usr/websm/bin/wjava $websmargs $javaargs -Dawt.appletWarning="Remote class window" com.ibm.websm.console.WConsole $hostname $profile $user $fastpath
